# -*- coding: utf-8 -*-
'''
Created on 2009. 9. 13.

@author: Administrator
'''
import httplib, urllib

def register_user_page_test():
    params = urllib.urlencode({'username' : 'bebeto', 'password1' : '30434', 'password2' : '30434', 'email' : 'manyfun@naver.com'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/accounts/register_user/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data
    
def login_page_test():
    params = urllib.urlencode({'username' : 'gunsbox', 'password' : '30434'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/accounts/login/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data
    
def logout_page_test():
#    params = urllib.urlencode({'username' : 'gunsbox', 'password' : '30434'})
    params = ''
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/accounts/logout/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data    
    
def register_baby_page_test():
    params = urllib.urlencode({'parent' : 'gunsbox', 'name' : '정이소두', 'birth' : '2009-05-16', 'gender' : 'M'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/accounts/register_baby/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data
    
def logging_height_page_test():
    params = urllib.urlencode({'baby' : '정이귀봉', 'record_date' : '2009-05-01', 'height' : '40'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/logging/height/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data                      
    
def logging_weight_page_test():
    params = urllib.urlencode({'baby' : '정이귀봉', 'record_date' : '2009-05-01', 'weight' : '7'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/logging/weight/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data
    
def logging_menu_page_test():
    params = urllib.urlencode({'baby' : '정이귀봉', 'record_date' : '2009-09-10', 'menu' : '호떡', 'capacity' : '1개'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/logging/menu/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data                      

def logging_dairy_page_test():
    params = urllib.urlencode({'baby' : '정이귀봉', 'record_date' : '2009-09-11', 'memo' : '오늘은 하루종일 코딩했다.'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/logging/dairy/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data                      
    
def logging_photo_test():
    params = urllib.urlencode({'baby' : '정이귀봉', 'record_date' : '2009-09-10', 'photo_file' : 'abcd.jpg', 'gps_info' : '192.149.594.492.394', 'voice_file' : 'abcd.wav', 'memo' : 'test...'})
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("POST", "/logging/photo/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data    

    
def dummy_test():
#    params = urllib.urlencode({'username' : 'gunsbox', 'password' : '30434'})
    params = ''
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("127.0.0.1:8000")
    conn.request("GET", "/dummy", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    conn.close()
    
    print data     
    
if __name__ == "__main__":
    register_user_page_test()
    login_page_test()    
    #dummy_test()
    register_baby_page_test()
    logout_page_test()
    logging_height_page_test()
    logging_weight_page_test()
    logging_menu_page_test()
    logging_dairy_page_test()
    logging_photo_test()
    
## -*- coding: utf-8 -*-
#'''
#Created on 2009. 9. 13.
#
#@author: Administrator
#'''
#import httplib, urllib
#
#def register_user_page_test():
#    params = urllib.urlencode({'username' : 'bebeto', 'password1' : '30434', 'password2' : '30434', 'email' : 'manyfun@naver.com'})
#    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
#    conn = httplib.HTTPConnection("127.0.0.1:8000")
#    conn.request("POST", "/accounts/register_user/", params, headers)
#    response = conn.getresponse()
#    print response.status, response.reason
#    data = response.read()
#    conn.close()
#    
#    print data
#    
#def login_page_test():
#    params = urllib.urlencode({'username' : 'gunsbox', 'password' : '30434'})
#    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
#    conn = httplib.HTTPConnection("127.0.0.1:8000")
#    conn.request("POST", "/accounts/login/", params, headers)
#    response = conn.getresponse()
#    print response.status, response.reason
#    data = response.read()
#    print data
#    
#    params = urllib.urlencode({'parent' : 'gunsbox', 'name' : '정이소두', 'birth' : '2009-05-16', 'gender' : 'M'})
#    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}      
#    conn.request("POST", "/accounts/register_baby/", params, headers)
#    response = conn.getresponse()
#    print response.status, response.reason
#    data = response.read()    
#    print data              
#
#    params = ''
#    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
#    conn.request("POST", "/accounts/logout/", params, headers)
#    response = conn.getresponse()
#    print response.status, response.reason
#    data = response.read()
#    conn.close()
#    
#    print data  
#  
#    
#def logout_page_test():
##    params = urllib.urlencode({'username' : 'gunsbox', 'password' : '30434'})
#    params = ''
#    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
#    conn = httplib.HTTPConnection("127.0.0.1:8000")
#    conn.request("POST", "/accounts/logout/", params, headers)
#    response = conn.getresponse()
#    print response.status, response.reason
#    data = response.read()
#    conn.close()
#    
#    print data    
#    
#def register_baby_page_test():
#    params = urllib.urlencode({'parent' : 'gunsbox', 'name' : '정이소두', 'birth' : '2009-05-16', 'gender' : 'M'})
#    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
#    conn = httplib.HTTPConnection("127.0.0.1:8000")
#    conn.request("POST", "/accounts/register_baby/", params, headers)
#    response = conn.getresponse()
#    print response.status, response.reason
#    data = response.read()
#    conn.close()
#    
#    print data              
#    
#def dummy_test():
##    params = urllib.urlencode({'username' : 'gunsbox', 'password' : '30434'})
#    params = ''
#    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
#    conn = httplib.HTTPConnection("127.0.0.1:8000")
#    conn.request("GET", "/dummy", params, headers)
#    response = conn.getresponse()
#    print response.status, response.reason
#    data = response.read()
#    conn.close()
#    
#    print data     
#    
#if __name__ == "__main__":
#
#    login_page_test()    
#    
#    

